/**
 * @copyright 2017 Indie Semiconductor.
 *
 * This file is proprietary to Indie Semiconductor.
 * All rights reserved. Reproduction or distribution, in whole
 * or in part, is forbidden except by express written permission
 * of Indie Semiconductor.
 *
 * @file pmu_device.h
 */

#ifndef __PMU_DEVICE_H__
#define __PMU_DEVICE_H__

#include <stddef.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include "rugby.h"

typedef enum{
    POLARITY_NATIVE = 0,
    POLARITY_FLIP,
}BattMonitorPolarity_t;


typedef enum{
  BOR_1V5_1310mV = 0,
  BOR_1V5_1340mV,
  BOR_1V5_1370mV,
  BOR_1V5_1400mV,
  
  BOR_1V5_1440mV,
  BOR_1V5_1480mV,
  BOR_1V5_1510mV,
  BOR_1V5_1560mV,
  
  BOR_1V5_1600mV,
  BOR_1V5_1640mV,
  BOR_1V5_1690mV,
  BOR_1V5_1740mV,
  
  BOR_1V5_1800mV,
  BOR_1V5_1920mV,
  BOR_1V5_2060mV,
  BOR_1V5_2210mV,
}Bor1V5Thres_t;


typedef enum{//????? erroe???
  BOR_3V3_2160mV = 0,
  BOR_3V3_2220mV,
  BOR_3V3_2290mV,
  BOR_3V3_2360mV,
  
  BOR_3V3_2430mV,
  BOR_3V3_2510mV,
  BOR_3V3_2590mV,
  BOR_3V3_2680mV,

  BOR_3V3_3250mV,
  BOR_3V3_3550mV,
  BOR_3V3_3910mV,
  BOR_3V3_4350mV,
}Bor3V3Thres_t;


void PMU_BORInit(Bor1V5Thres_t lowThreshold, Bor3V3Thres_t highThreshold);


/**
 * @brief The enumeration of brownout mode.
 */
typedef enum {
    PMU_BROWNOUT_RESET = 0,
    PMU_BROWNOUT_INTERRUPT,
    PMU_BROWNOUT_NONE,
} PMU_BROWNOUT_MODE_t;

/**
 * @brief Initialize brownout reset.
 *
 * @param volt The brownout voltage.
 * @return 0 for success or error code upon a failure.
*/
int32_t PMU_devBrownOutResetInit(uint8_t volt);

/**
 * @brief Initialize brownout interrupt.
 *
 * @param volt The brownout voltage.
 * @param cb The pointer to the call back function for brown interrupt.
 * @return 0 for success or error code upon a failure.
 */
int32_t PMU_devBrownOutInterruptInit(uint8_t volt, void *cb);

/**
 * @brief Disable brownout.
 *
 * @param none.
 * @return none.
 */
void PMU_devBrownOutDisable(void);

#endif /* __PMU_DEVICE_H__ */
